Download the source code in this example and run:
Production process:
1. After creating a new project, add form2, form3, form4, and form5;
2. Add a tprogressbar and tlabel respectively on form5 (use the default name );
3. Open the project source code (Project-> View Source) and paste the following files to run the program.
Program project1; uses forms, sysutils, unit1 in 'unit1. PAS '{form1}, unit2 in 'unit2. pa' {form2}, unit3 in 'unit3. pa' {form3}, unit4 in 'unit4. pa' {form
mainform must be the first form in all forms created by method CreateForm, but the form is not necessarily the main window of the application. When you create a new project, the MainForm property value is automatically set to Form1. Available at design time via project| The Forms page in the Options dialog box specifies that one of them is mainform in multiple forms.The MainForm property cannot be modified at run time because the property is read-onl
Connection Library.Ii. Dynamic Connection Library callFirst, make a call declaration under implementation.ConstGdi32 = 'mydll. dll ';Function triple (n: integer): integer; stdcall; external gdi32 name 'tr ';Function Double (N: Integer): integer; stdcall; external gdi32 name 'do ';Function triple1 (n: integer): integer; stdcall; external gdi32 name 'trm ';Function Double1 (N: Integer): integer; stdcall; external gdi32 name 'dom ';In the future, the program can be used as a common function, for e
information 10) if the application closes or calls the tapplication. if the terminate () method is used, the terminate attribute is T. Ure} {tapplication method 1) createform method procedure createform (instanceclass: tcomponentclass; var reference); instanceclass specifies the class reference of the form to return the instance of the Form 2) handleexception is used to display the exception information in
Click on that button and the form will appear.
If it's a lot of buttons, is that what we usually write?
The code is as follows
Copy Code
private void Button3_Click (object sender, EventArgs e){Get the button name that you clickedString btnname = ((Button) sender). Name;if (Btnname = = "Button1"){Working with Forms}else if (btnname = "Button2"){Working with Forms}Else{Working with Forms}}
This can only be done in a single, if more than 100 thousand will not
, which are often used for synchronization between threads.
Technology
Means. A Brief Introduction of mutex object: The mutex object uses the program that was created for the first time as the main program. In this way, it only checks whether the mutex object has been run by the main program to determine whether the program has been run, here we need to involve an API function: waitforsingleobject. The first parameter of this function is the mutex object used for detection. The first param
. When the program is running, enumerate existing windows in the system. If the program is found to be running, send a custom message to the window and end. A window is displayed when a running program receives a custom message.
// Project file procviewpro. DPRProgram procviewpro;
UsesForms, windows, messages, main in 'procview. pa' {form1 };
{$ R *. Res}{// This is automatic.BeginApplication. initialize;Application. Title: = 'System Process Monitoring ';Application.
: // if it is a CGI/ISAPI application, you need to create datamodule1. For the corresponding changes, see the description later. // open clientdataset and construct tdatasetpack, // disable clientdataset and database connection // return result tdatasetpack * tdatatableimpl: getemployeetable (void) {// for CGI/ISAPI, this sentence is required. // application-> createform (_ classid (tdatamodule1), datamodule1); datamodule1-> clientdataset1-> open ();
1. Create a mutex object
Create a mutex object in project project1.dpr
Program project1
Uses
Windows, form,
Frmmain in 'frmmain. pa' {mainform };
{$ R *. Res}
VaR
Happmutex: thandle; // declare the mutex variable
Begin
Happmutex: = createmutex (nil, false, 'projectname'); // create a mutually exclusive object projectname project name
If (happmutex
Begin // happmutex
MessageBox ('the program is running. Close this window according to OK! ',' Prompt! ', Mb_ OK );
End
Else
Begin
Application. inin
not (@ShowForm = nil) ThenShowForm (Application.handle, ' personnel Information management ')//Call out FormElseRaiselastwin32error;FinallyFreeLibrary (Libhandle); Unload the DLL.EndEnd============== END ==================second section DLL in the Delphi formFirst, the steps to implement form reuse using DLLs are:1. In the Integrated development environment (IDE), design a form according to your own needs;2. Write a function or procedure for the output. in this function or procedure, the design
application ' s main form (Form1); and Unit2, which are associated with Anoth Er form (Form2). The program makes a series of calls to an object named application, which are an instance of the Vcl.Forms.TApplication class defined in the Forms unit. (Every project has an automatically generated Application object.) The these calls invoke a Vcl.Forms.TApplication method named CreateForm. The first call to Create
. initialize;Application. createform (tform1, form1 );Application. Run;End;End;
The findwindow () function has two parameters, one of which can be ignored. However, I strongly recommend that you set the two parametersSo that other programs are using the same class name and cannot get the correct result. In additionIf you run this program in the Delphi ide window, it cannot be run at one time because a window with the same class name and title already
indicates that the mutex object already has a main program. Modified project file Code (Note: The following code appears in the project file, rather than in the unit file, and is modified on the basis of the simplest default project created by Delphi)VaRMymutex: hwnd;BeginMymutex: = createmutex (nil, false, 'hkonecopy'); // createmutex creates a mutex object and gives it a unique name. If waitforsingleobject (mymutex, 0) BeginApplication. initialize;Application.
$request){ $form = $this->createForm(...); $form->bindRequest($request); // ...}
Controller base class
For convenience, Symfony2 defines a Controller base class, which includes some common controller tasks and provides your controller class with access to any resources you need. By inheriting this class, you can get many help methods.
// src/Acme/HelloBundle/Controller/HelloController.phpnamespace Acme\HelloBundle\Controller;use Symfony\Bundle\Fram
class object by ourselves? Of course!
VaR myscreen: tscreen; begin myscreen: = tscreen. create (NiL); {create} showmessage (inttostr (myscreen. width); {display: 1024; my screen resolution is 1024*768} myscreen. free; {release} myscreen: = nil; {root disconnection} end;Tscreen-number of forms in the program// An example containing two forms: Program project1; uses forms, unit1 in 'unit1. PAS '{form1}, unit2 in 'unit2. PAS '{form2}; {$ R *. res} begin application. initialize; application. main
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.